home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "SaveVersion"
- Sub BackupSpeichen()
- Dim fso, msg
- 'Pfad zu "Eigene Dateien" ermitteln
- Set WshShell = CreateObject("WScript.Shell")
- myDocumentsPath = WshShell.SpecialFolders("MyDocuments")
- 'Backupverzeichnis festlegen
- myBackupDir = myDocumentsPath & "\" & "Backup" & "\"
- 'Backupverzeichnis erstellen wenn nicht vorhanden
- Set fso = CreateObject("Scripting.FileSystemObject")
- If Not (fso.FolderExists(myBackupDir)) Then MkDir myBackupDir
- 'Dokument schon gespeichert?
- If Not Application.ActiveDocument.FullName = Application.ActiveDocument.Name Then
- 'diverse Variablen festlegen
- myFilePath = Application.ActiveDocument.FullName
- myFileName = Application.ActiveDocument.Name
- myDocName = Mid(myFileName, 1, InStr(myFileName, "."))
- DocVersion = ActiveDocument.BuiltInDocumentProperties("Revision Number")
- myExt = Mid(myFileName, InStr(myFileName, "."), Len(myFileName))
- myDate = Year(Date) & Month(Date) & Day(Date)
- myTime = Hour(Time) & "." & Minute(Time) & "." & Second(Time)
- myVer = DocVersion & "_" & myDate & "_" & myTime
- 'Varianten
- 'myVer = DocVersion
- 'oder
- 'myVer = "_" & myDate & "_" & myTime
- 'aktuelles Dukument kopieren
- If Left$(Application.Version, 1) = "8" Then
- 'Word 97
- WordBasic.CopyFile Filename:=myFilePath, _
- Directory:=myBackupDir & myDocName & myVer & myExt
- Else
- 'Word 2000/XP
- WordBasic.CopyFileA Filename:=myFilePath, _
- Directory:=myBackupDir & myDocName & myVer & myExt
- End If
-
- Else
- MsgBox ("Sie mⁿssen das Dokument erst speichern.")
- End If
-
- End Sub
-
-